﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormCinemabooking
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        #region       User Menu
        private void btnUsers_Click(object sender, EventArgs e)
        {
            ServiceReferenceUser.UserServiceClient service = new ServiceReferenceUser.UserServiceClient();
            splitContainer1.Panel2.Controls.Clear();
            InitializeUserComponent();

            var allUser = service.GetAllUsers();
            dataGridView2.DataSource = allUser;
        }

        private void btnDelUser_Click(object sender, EventArgs e)
        {
            ServiceReferenceUser.UserServiceClient service = new ServiceReferenceUser.UserServiceClient();
            service.DeleteUser(Convert.ToInt32(txtUserId.Text));

            var refresh = service.GetAllUsers();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);
        }

        private void btnSaveUser_Click(object sender, EventArgs e)
        {
            ServiceReferenceUser.UserServiceClient service = new ServiceReferenceUser.UserServiceClient();

            string _name = txtUserName.Text;
            string _address = txtUserAddress.Text;
            string _password = txtUserPassword.Text;
            string _phone = txtUserPhone.Text;
            string _email = txtUserEmail.Text;

            service.SaveUser(_name, _address, _password, _phone, _email);
            var refresh = service.GetAllUsers();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);

        }

        private void btnUpdUser_Click(object sender, EventArgs e)
        {
            ServiceReferenceUser.UserServiceClient service = new ServiceReferenceUser.UserServiceClient();

            int _id = Convert.ToInt32(txtUserId.Text);
            string _name = txtUserName.Text;
            string _address = txtUserAddress.Text;
            string _password = txtUserPassword.Text;
            string _phone = txtUserPhone.Text;
            string _email = txtUserEmail.Text;

            service.UpdateUser(_id, _name, _address, _password, _phone, _email);
            var refresh = service.GetAllUsers();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);

        }

        private void btnSearchUser_Click(object sender, EventArgs e)
        {
            ServiceReferenceUser.UserServiceClient service = new ServiceReferenceUser.UserServiceClient();

            var user = service.GetUserById(Convert.ToInt32(txtUserId.Text));
            dataGridView2.DataSource = user;
            ClearBoxes(this);
        }
        #endregion

        #region MovieInfo Menu
        private void btnMovieinfo_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieInfo.MovieInfoServiceClient service = new ServiceReferenceMovieInfo.MovieInfoServiceClient();
            splitContainer1.Panel2.Controls.Clear();
            InitializeMovieInfoComponent();

            var allMov = service.GetAllMovies();
            dataGridView2.DataSource = allMov;

        }

        private void btnDelMovInfo_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieInfo.MovieInfoServiceClient service = new ServiceReferenceMovieInfo.MovieInfoServiceClient();
            service.DeleteMovie(Convert.ToInt32(txtMovId.Text));

            var refresh = service.GetAllMovies();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);
        }

        private void btnSaveMovInfo_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieInfo.MovieInfoServiceClient service = new ServiceReferenceMovieInfo.MovieInfoServiceClient();

            string _movName = txtMovName.Text;
            string _movGenre = txtMovGenre.Text;
            string _movType = txtMovType.Text;
            string _movDesc = txtMovDesc.Text;
            string _movPic = txtMovPic.Text;
            int _movTheater = Convert.ToInt32(txtMovTheater.Text);
            string _movTrailer = txtMovTrailer.Text;

            service.SaveMovie(_movName, _movGenre, _movType, _movDesc, _movPic, _movTheater, _movTrailer);
            var refresh = service.GetAllMovies();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);
        }

        private void btnUpdMovInfo_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieInfo.MovieInfoServiceClient service = new ServiceReferenceMovieInfo.MovieInfoServiceClient();

            int _movId = Convert.ToInt32(txtMovId.Text);
            string _movName = txtMovName.Text;
            string _movGenre = txtMovGenre.Text;
            string _movType = txtMovType.Text;
            string _movDesc = txtMovDesc.Text;
            string _movPic = txtMovPic.Text;
            int _movTheater = Convert.ToInt32(txtMovTheater.Text);
            string _movTrailer = txtMovTrailer.Text;

            service.UpdateMovie(_movId, _movName, _movGenre, _movType, _movDesc, _movPic, _movTheater, _movTrailer);
            var refresh = service.GetAllMovies();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);
        }

        private void btnSearchMovInfo_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieInfo.MovieInfoServiceClient service = new ServiceReferenceMovieInfo.MovieInfoServiceClient();

            var movInfo = service.GetMovieById(Convert.ToInt32(txtMovId.Text));
            dataGridView2.DataSource = movInfo;
            ClearBoxes(this);
        }
        #endregion

        #region Movie Runtimes MenuSelectedValue
        private void btnRuntime_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient runtimesService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();
            ServiceReferenceMovieInfo.MovieInfoServiceClient movInfoService = new ServiceReferenceMovieInfo.MovieInfoServiceClient();
            ServiceReferenceTheaters.TheaterServiceClient theaterService = new ServiceReferenceTheaters.TheaterServiceClient();
            ServiceReferenceStartTime.StartTimesServiceClient timeService = new ServiceReferenceStartTime.StartTimesServiceClient();
            ServiceReferenceDates.DatesServiceClient dateService = new ServiceReferenceDates.DatesServiceClient();

            splitContainer1.Panel2.Controls.Clear();
            InitializeMovieRuntimeComponents();

            var allRuntime = runtimesService.GetAllRunTime();
            dataGridView2.DataSource = allRuntime;

            cbMovName.ValueMember = "name";
            cbMovName.DisplayMember = "name";
            cbMovName.DataSource = movInfoService.GetAllMovies();

            cbStartTime.ValueMember = "movieStart";
            cbStartTime.DisplayMember = "movieStart";
            cbStartTime.DataSource = timeService.GetAllStartTimes();

            cbDate.ValueMember = "date1";
            cbDate.DisplayMember = "date1";
            cbDate.DataSource = dateService.GetAllDates();

        }

        private void btnDelMovRunTime_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient runtimeService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();
            runtimeService.DeleteRunTime(Convert.ToInt32(txtRuntimeId.Text));

            var refresh = runtimeService.GetAllRunTime();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);
        }

        private void btnSaveMovRunTime_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient runtimeService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();

            string _movName = Convert.ToString(cbMovName.SelectedValue);
            int _theater = Convert.ToInt32(txtTheaterId.Text);
            string _start = Convert.ToString(cbStartTime.SelectedValue);
            string _date = Convert.ToString(cbDate.SelectedValue);

            runtimeService.SaveRunTime(_movName, _theater, _start, _date);
            var refresh = runtimeService.GetAllRunTime();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);

        }

        private void btnUpdMovRunTime_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient runtimeService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();

            int _runId = Convert.ToInt32(txtRuntimeId.Text);
            string _movName = Convert.ToString(cbMovName.SelectedValue);
            int _theater = Convert.ToInt32(txtTheaterId.Text);
            string _start = Convert.ToString(cbStartTime.SelectedValue);
            string _date = Convert.ToString(cbDate.SelectedValue);

            runtimeService.UpdateRunTime(_runId, _movName, _theater, _start, _date);
            var refresh = runtimeService.GetAllRunTime();
            dataGridView2.DataSource = refresh;
            ClearBoxes(this);
        }

        private void btnSearchMovRunTime_Click(object sender, EventArgs e)
        {
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient service = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();

            var runInfo = service.GetRunTime(Convert.ToInt32(txtRuntimeId.Text));
            dataGridView2.DataSource = runInfo;
            ClearBoxes(this);
        }
        #endregion

        #region Make Booking Menu
        private void btnMakeBook_Click(object sender, EventArgs e)
        {
            ServiceReferenceBooking.BookingServiceClient bookService = new ServiceReferenceBooking.BookingServiceClient();

            splitContainer1.Panel2.Controls.Clear();
            InitializeMakeBookComponents();

            var allBookings = bookService.GetAllBookings();
            dataGridView2.DataSource = allBookings;

        }

        private void btnDelBooking_Click(object sender, EventArgs e)
        {
            ServiceReferenceBooking.BookingServiceClient bookingService = new ServiceReferenceBooking.BookingServiceClient();
            ServiceReferenceBookedseats.BookedSeatsServiceClient bookedService = new ServiceReferenceBookedseats.BookedSeatsServiceClient();
            ServiceReferenceSeats.SeatsServiceClient seatService = new ServiceReferenceSeats.SeatsServiceClient();

            seatService.SetSeatsToAvalible(txtCusName.Text);
            bookedService.DeleteBookedSeatsOnPhoneNr(txtCusName.Text);
            bookingService.DeleteBooking(txtCusName.Text);

            ClearBoxes(this);
            var refresh = bookingService.GetAllBookings();
            dataGridView2.DataSource = refresh;
        }

        private void btnSaveBooking_Click(object sender, EventArgs e)
        {
            ServiceReferenceBooking.BookingServiceClient bookingService = new ServiceReferenceBooking.BookingServiceClient();
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient movieRunService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();
            ServiceReferenceMovieInfo.MovieInfoServiceClient movieInfoService = new ServiceReferenceMovieInfo.MovieInfoServiceClient();
            ServiceReferenceDates.DatesServiceClient movDateService = new ServiceReferenceDates.DatesServiceClient();
            ServiceReferenceTickets.TicketsServiceClient ticketsService = new ServiceReferenceTickets.TicketsServiceClient();

            string _cusPhone = txtCusPhonenr.Text;
            string _cusName = txtCusName.Text;
            

            if (checkForPhoneNr(_cusName) != true)
            {                
                    MessageBox.Show("ERROR Not Valid Phone Number !");                                
            }
            else if (checkForName(_cusPhone) != true)
            {
                MessageBox.Show("ERROR Not Valid Name !");
            }
            else
            {
                bookingService.SaveBooking(_cusPhone, _cusName);
                var refresh = bookingService.GetAllBookings();
                dataGridView2.DataSource = refresh;

                splitContainer1.Panel2.Controls.Remove(txtCusPhonenr);
                splitContainer1.Panel2.Controls.Remove(lblCusName);
                txtCusName.ReadOnly = true;
                splitContainer1.Panel2.Controls.Remove(btnSaveBooking);
                InitializeBookedSeatsComponents();

                cbBookedSeatMovInfo.DataSource = movieInfoService.GetAllMovies();
                cbBookedSeatMovInfo.ValueMember = "name";
                cbBookedSeatMovInfo.DisplayMember = "name";
                cbBookedSeatMovInfo.SelectedIndex = -1;

                cbBookedSeatMovDate.DataSource = movDateService.GetAllDates();
                cbBookedSeatMovDate.ValueMember = "date1";
                cbBookedSeatMovDate.DisplayMember = "date1";
                cbBookedSeatMovDate.SelectedIndex = -1;

                cbTicketAmount.DataSource = ticketsService.GetAllTickets();
                cbTicketAmount.ValueMember = "amount";
                cbTicketAmount.DisplayMember = "amount";                             
            }

        }      

        private void cbTicketAmount_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceRows.RowsServiceClient rowsService = new ServiceReferenceRows.RowsServiceClient();

            string _amountOfTickets = Convert.ToString(cbTicketAmount.SelectedValue);

            if (_amountOfTickets == "1")
            {
                gboxSeat2.Visible = false;
                gboxSeat3.Visible = false;
                gboxSeat4.Visible = false;
                gboxSeat5.Visible = false;
            }

            if (_amountOfTickets == "2")
            {
                gboxSeat2.Visible = true;
                gboxSeat3.Visible = false;
                gboxSeat4.Visible = false;
                gboxSeat5.Visible = false;

                if (gboxSeat2.Visible == true)
                {
                    cbRow2.DisplayMember = "rowNumber";
                    cbRow2.ValueMember = "id";
                    cbRow2.DataSource = rowsService.GetAllRows();
                    cbRow2.SelectedValue = -1;
                }
            }

            if (_amountOfTickets == "3")
            {
                gboxSeat2.Visible = true;
                gboxSeat3.Visible = true;
                gboxSeat4.Visible = false;
                gboxSeat5.Visible = false;

                if (gboxSeat3.Visible == true)
                {
                    cbRow2.DisplayMember = "rowNumber";
                    cbRow2.ValueMember = "id";
                    cbRow2.DataSource = rowsService.GetAllRows();
                    cbRow2.SelectedValue = -1;

                    cbRow3.DisplayMember = "rowNumber";
                    cbRow3.ValueMember = "id";
                    cbRow3.DataSource = rowsService.GetAllRows();
                    cbRow3.SelectedValue = -1;
                }

            }

            if (_amountOfTickets == "4")
            {
                gboxSeat2.Visible = true;
                gboxSeat3.Visible = true;
                gboxSeat4.Visible = true;
                gboxSeat5.Visible = false;

                if (gboxSeat4.Visible == true)
                {
                    cbRow2.DisplayMember = "rowNumber";
                    cbRow2.ValueMember = "id";
                    cbRow2.DataSource = rowsService.GetAllRows();
                    cbRow2.SelectedValue = -1;

                    cbRow3.DisplayMember = "rowNumber";
                    cbRow3.ValueMember = "id";
                    cbRow3.DataSource = rowsService.GetAllRows();
                    cbRow3.SelectedValue = -1;

                    cbRow4.DisplayMember = "rowNumber";
                    cbRow4.ValueMember = "id";
                    cbRow4.DataSource = rowsService.GetAllRows();
                    cbRow4.SelectedValue = -1;
                }
            }

            if (_amountOfTickets == "5")
            {
                gboxSeat2.Visible = true;
                gboxSeat3.Visible = true;
                gboxSeat4.Visible = true;
                gboxSeat5.Visible = true;

                if (gboxSeat5.Visible == true)
                {
                    cbRow2.DisplayMember = "rowNumber";
                    cbRow2.ValueMember = "id";
                    cbRow2.DataSource = rowsService.GetAllRows();
                    cbRow2.SelectedValue = -1;

                    cbRow3.DisplayMember = "rowNumber";
                    cbRow3.ValueMember = "id";
                    cbRow3.DataSource = rowsService.GetAllRows();
                    cbRow3.SelectedValue = -1;

                    cbRow4.DisplayMember = "rowNumber";
                    cbRow4.ValueMember = "id";
                    cbRow4.DataSource = rowsService.GetAllRows();
                    cbRow4.SelectedValue = -1;

                    cbRow5.DisplayMember = "rowNumber";
                    cbRow5.ValueMember = "id";
                    cbRow5.DataSource = rowsService.GetAllRows();
                    cbRow5.SelectedValue = -1;
                }
            }

        }

        private void cbBookedSeatMovDate_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceMovieRunTime.MovieRunTimeServiceClient movRunService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();

            string _selectedMovName = Convert.ToString(cbBookedSeatMovInfo.SelectedValue);
            string _selectedMovDate = Convert.ToString(cbBookedSeatMovDate.SelectedValue);

            cbBookedSeatMovTime.DisplayMember = "startTime";
            cbBookedSeatMovTime.ValueMember = "id";
            cbBookedSeatMovTime.DataSource = movRunService.GetRunTimeOnMovNameAndDate(_selectedMovName, _selectedMovDate);
            cbBookedSeatMovTime.SelectedIndex = -1;
        }

        private void cbBookedSeatMovTime_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceRows.RowsServiceClient rowsService = new ServiceReferenceRows.RowsServiceClient();

            cbRow1.DisplayMember = "rowNumber";
            cbRow1.ValueMember = "id";
            cbRow1.DataSource = rowsService.GetAllRows();
            cbRow1.SelectedValue = -1;
        }

        private void cbRow1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceSeats.SeatsServiceClient seatsService = new ServiceReferenceSeats.SeatsServiceClient();

            int _rowId = Convert.ToInt32(cbRow1.SelectedValue);
            int _runTimeId = Convert.ToInt32(cbBookedSeatMovTime.SelectedValue);

            cbSeat1.DataSource = seatsService.GetSeatsOnRowAndRunTime(_rowId, _runTimeId);
            cbSeat1.ValueMember = "id";
            cbSeat1.DisplayMember = "seatNr";
            cbSeat1.SelectedIndex = -1;
        }

        private void cbRow2_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceSeats.SeatsServiceClient seatsService = new ServiceReferenceSeats.SeatsServiceClient();

            int _rowId = Convert.ToInt32(cbRow2.SelectedValue);
            int _runTimeId = Convert.ToInt32(cbBookedSeatMovTime.SelectedValue);

            cbSeat2.DisplayMember = "seatNr";
            cbSeat2.ValueMember = "id";
            cbSeat2.DataSource = seatsService.GetSeatsOnRowAndRunTime(_rowId, _runTimeId);
            cbSeat2.SelectedIndex = -1;
        }

        private void cbRow3_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceSeats.SeatsServiceClient seatsService = new ServiceReferenceSeats.SeatsServiceClient();

            int _rowId = Convert.ToInt32(cbRow3.SelectedValue);
            int _runTimeId = Convert.ToInt32(cbBookedSeatMovTime.SelectedValue);

            cbSeat3.DisplayMember = "seatNr";
            cbSeat3.ValueMember = "id";
            cbSeat3.DataSource = seatsService.GetSeatsOnRowAndRunTime(_rowId, _runTimeId);
            cbSeat3.SelectedIndex = -1;
        }

        private void cbRow4_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceSeats.SeatsServiceClient seatsService = new ServiceReferenceSeats.SeatsServiceClient();

            int _rowId = Convert.ToInt32(cbRow4.SelectedValue);
            int _runTimeId = Convert.ToInt32(cbBookedSeatMovTime.SelectedValue);

            cbSeat4.DataSource = seatsService.GetSeatsOnRowAndRunTime(_rowId, _runTimeId);
            cbSeat4.ValueMember = "id";
            cbSeat4.DisplayMember = "seatNr";
            cbSeat4.SelectedIndex = -1;
        }

        private void cbRow5_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServiceReferenceSeats.SeatsServiceClient seatsService = new ServiceReferenceSeats.SeatsServiceClient();

            int _rowId = Convert.ToInt32(cbRow5.SelectedValue);
            int _runTimeId = Convert.ToInt32(cbBookedSeatMovTime.SelectedValue);

            cbSeat5.DataSource = seatsService.GetSeatsOnRowAndRunTime(_rowId, _runTimeId);
            cbSeat5.ValueMember = "id";
            cbSeat5.DisplayMember = "seatNr";
            cbSeat5.SelectedIndex = -1;
        }

        private void btnSearchBooking_Click(object sender, EventArgs e)
        {
            ServiceReferenceBooking.BookingServiceClient bookingService = new ServiceReferenceBooking.BookingServiceClient();

            var bookInfo = bookingService.GetBookingOnPhone(txtCusPhonenr.Text);
            dataGridView2.DataSource = bookInfo;
        }
        #endregion

        #region Booked Seat
        private void btnSaveBookedSeat_Click(object sender, EventArgs e)
        {
            ServiceReferenceBookedseats.BookedSeatsServiceClient bookSeatService = new ServiceReferenceBookedseats.BookedSeatsServiceClient();
            ServiceReferenceSeats.SeatsServiceClient seatService = new ServiceReferenceSeats.SeatsServiceClient();
            ServiceReferenceBooking.BookingServiceClient bookingService = new ServiceReferenceBooking.BookingServiceClient();


            int _seatInfo1 = Convert.ToInt32(cbSeat1.SelectedValue);
            int _movInfo = Convert.ToInt32(cbBookedSeatMovTime.SelectedValue);
            string _bookInfo = txtCusName.Text;
            string _movName = cbBookedSeatMovInfo.Text;
            string _dateInfo = cbBookedSeatMovDate.Text;
            string _timeInfo = cbBookedSeatMovTime.Text;
            string _rowInfo = cbRow1.Text;
            string _seat1Info = cbSeat1.Text;
            string _seat2Info = cbSeat2.Text;
            string _seat3Info = cbSeat3.Text;
            string _seat4Info = cbSeat4.Text;
            string _seat5Info = cbSeat5.Text;
            string _amountInfo = cbTicketAmount.Text;
            string _priceInfo = "";


            bookSeatService.SaveBookedSeat(_seatInfo1, _bookInfo, _movInfo);
            seatService.UpdateAvalibility(_seatInfo1);
            
            #region Check if gbox is visible
            if (gboxSeat2.Visible != false && cbRow2.SelectedIndex != -1)
            {
                int _seatInfo2 = Convert.ToInt32(cbSeat2.SelectedValue);

                bookSeatService.SaveBookedSeat(_seatInfo2, _bookInfo, _movInfo);
                seatService.UpdateAvalibility(_seatInfo2);
            }

            if (gboxSeat3.Visible != false && cbRow3.SelectedIndex != -1)
            {
                int _seatInfo3 = Convert.ToInt32(cbSeat3.SelectedValue);

                bookSeatService.SaveBookedSeat(_seatInfo3, _bookInfo, _movInfo);
                seatService.UpdateAvalibility(_seatInfo3);
            }

            if (gboxSeat4.Visible != false && cbRow4.SelectedIndex != -1)
            {
                int _seatInfo4 = Convert.ToInt32(cbSeat4.SelectedValue);

                bookSeatService.SaveBookedSeat(_seatInfo4, _bookInfo, _movInfo);
                seatService.UpdateAvalibility(_seatInfo4);
            }

            if (gboxSeat5.Visible != false && cbRow5.SelectedIndex != -1)
            {
                int _seatInfo5 = Convert.ToInt32(cbSeat5.SelectedValue);

                bookSeatService.SaveBookedSeat(_seatInfo5, _bookInfo, _movInfo);
                seatService.UpdateAvalibility(_seatInfo5);
            }
            #endregion

            #region Figure out price
            if (_amountInfo == "1")
            {
                _priceInfo = "95";
            }
            else if (_amountInfo == "2")
            {
                _priceInfo = "190";
            }
            else if (_amountInfo == "3")
            {
                _priceInfo = "285";
            }
            else if (_amountInfo == "4")
            {
                _priceInfo = "380";
            }
            else if (_amountInfo == "5")
            {
                _priceInfo = "475";
            }
            #endregion
                        
            MessageBox.Show("Booking Succes! \n" +
                            "\n" +
                            "Movie: " + _movName +
                            "\n" +
                            "\n" +
                            "Date: " + _dateInfo + ", Time: " + _timeInfo + "\n" +
                            "Row Nr: " + _rowInfo + "\n" +
                            "Seat Nr: " + _seat1Info + " " + _seat2Info + " " + _seat3Info + " " + _seat4Info + " " + _seat5Info + "\n" +
                            "Amount Of Tickets: " + _amountInfo + "\n" +
                            "Price: " + _priceInfo + " Kr."
                );

            splitContainer1.Panel2.Controls.Clear();
            InitializeMakeBookComponents();

        }

        #endregion

        #region Regular expressions
        public static bool checkForPhoneNr(string phonenr)
        {
            bool isValid = false;
            Regex r = new Regex("[0-9]{8}");
            if (r.IsMatch(phonenr))
                isValid = true;
            return isValid;
        }

        public static bool checkForName(string name)
        {
            bool isValid = false;
            Regex r = new Regex("[a-zA-Z]{2,20}");
            if (r.IsMatch(name))
                isValid = true;
            return isValid;
        }
        #endregion

        #region Method for clearing all textboxes and comboboxes in panel
        public static void ClearBoxes(Control control)
        {
            foreach (Control c in control.Controls)
            {
                var textBox = c as TextBox;
                var comboBox = c as ComboBox;

                if (textBox != null)
                    (textBox).Clear();

                if (comboBox != null)
                    comboBox.SelectedIndex = -1;

                if (c.HasChildren)
                    ClearBoxes(c);
            }
        }
        #endregion

    }
}
